import 'dart:io';

import 'package:animal/constant/index_constant.dart';
import 'package:animal/ui/login/controller/perfect_info_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///完善信息
class PerfectInfoPage extends StatelessWidget {
  PerfectInfoPage({Key? key}) : super(key: key);
  final controller = Get.put(PerfectInfoController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: KColorConstant.white,
      appBar: AppBarWidget.defaultAppBar(
        backgroundColor: Colors.white,
        leading: InkWell(child: const Icon(Icons.arrow_back_ios, color: Colors.black), onTap: () => Get.back()),
        centerTitle: true,
        title: Text("完善信息", style: KFontConstant.myTextStyle(size: 20, color: Colors.black, bold: true)),
        elevation: 0,
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(60), vertical: ScreenUtil().L(25)),
        child: Column(
          children: [
            InkWell(
              onTap: () => controller.selectedImage(),
              child: Obx(() {
                return Container(
                  width: ScreenUtil().L(85),
                  height: ScreenUtil().L(85),
                  margin: EdgeInsets.only(bottom: ScreenUtil().L(15)),
                  decoration: BoxDecoration(
                    color: const Color(0XFFF0F0F0),
                    borderRadius: BorderRadius.circular(ScreenUtil().L(10)),
                  ),
                  child: controller.filePath.value == ""
                      ? Image.asset(
                          "images/info_head.png",
                          width: ScreenUtil().L(85),
                        )
                      : ClipRRect(
                          child: Image.file(File(controller.filePath.value), fit: BoxFit.cover),
                          borderRadius: BorderRadius.circular(ScreenUtil().L(10)),
                        ),
                );
              }),
            ),
            Text("上传头像", style: KFontConstant.myTextStyle(size: 16, bold: true)),
            Container(
              margin: EdgeInsets.only(top: ScreenUtil().L(30)),
              decoration: BoxDecoration(border: Border(bottom: BorderSide(color: const Color(0xFFEEEEEE), width: ScreenUtil().L(0.8)))),
              child: TextField(
                style: KFontConstant.myTextStyle(size: 15),
                controller: controller.controller,
                maxLength: 10,
                decoration: InputDecoration(
                    hintText: "请输入昵称",
                    hintStyle: KFontConstant.myTextStyle(size: 15, color: KColorConstant.black666666),
                    border: InputBorder.none,
                    counterText: ""),
              ),
            ),
            Container(
              width: double.infinity,
              margin: EdgeInsets.only(top: ScreenUtil().L(10)),
              padding: EdgeInsets.symmetric(vertical: ScreenUtil().L(15)),
              decoration: BoxDecoration(border: Border(bottom: BorderSide(color: const Color(0xFFEEEEEE), width: ScreenUtil().L(0.8)))),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text("请选择性别", style: KFontConstant.myTextStyle(size: 15, color: KColorConstant.black666666)),
                  Row(
                    children: [
                      Obx(
                        () => GFCheckbox(
                          size: ScreenUtil().L(20),
                          type: GFCheckboxType.circle,
                          inactiveBorderColor: const Color(0XFFB5B5B5),
                          activeIcon: Image.asset("icons/icon_check_blue_two.png"),
                          onChanged: (value) {
                            controller.checkTap(value);
                          },
                          value: !controller.checkBtn.value,
                        ),
                      ),
                      Container(width: ScreenUtil().L(8)),
                      Text("先生",
                          style: KFontConstant.myTextStyle(
                            size: 16,
                            color: KColorConstant.black666666,
                          )),
                      Container(width: ScreenUtil().L(30)),
                      Obx(
                        () => GFCheckbox(
                          size: ScreenUtil().L(20),
                          type: GFCheckboxType.circle,
                          inactiveBorderColor: const Color(0XFFB5B5B5),
                          activeIcon: Image.asset("icons/icon_check_blue_two.png"),
                          onChanged: (value) {
                            controller.checkTap(value);
                          },
                          value: controller.checkBtn.value,
                        ),
                      ),
                      Container(width: ScreenUtil().L(8)),
                      Text("女士",
                          style: KFontConstant.myTextStyle(
                            size: 16,
                            color: KColorConstant.black666666,
                          )),
                    ],
                  ),
                ],
              ),
            ),
            Container(height: ScreenUtil().L(40)),
            CupertinoButton(
                onPressed: () => controller.prefectInfo(),
                borderRadius: BorderRadius.circular(ScreenUtil().L(5)),
                color: KColorConstant.btnColor19ACE5,
                child: Text("完成", style: KFontConstant.myTextStyle(size: 16, color: Colors.white, bold: true))),
            Container(
              margin: EdgeInsets.symmetric(vertical: ScreenUtil().L(30)),
              decoration: BoxDecoration(
                  border: Border.all(color: KColorConstant.btnColor19ACE5, width: ScreenUtil().L(0.7)), borderRadius: BorderRadius.circular(ScreenUtil().L(5))),
              child: CupertinoButton(
                  onPressed: () => controller.gotoHomeIndex(),
                  borderRadius: BorderRadius.circular(ScreenUtil().L(5)),
                  color: const Color(0X00000000),
                  child: Text("跳过", style: KFontConstant.myTextStyle(size: 16, color: KColorConstant.btnColor19ACE5, bold: true))),
            ),
          ],
        ),
      ),
    );
  }
}
